
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>修改密码</title>
		<link href="../easyui/css/bootstrap.css?v=202003150000" rel="stylesheet" type="text/css">
		<link href="../easyui/css/easyui.css?v=202003150000" rel="stylesheet" type="text/css">
		<link href="../easyui/css/color.css?v=202003150000" rel="stylesheet" type="text/css">
		<link href="../easyui/css/font-awesome.min.css?v=202003150000" rel="stylesheet" type="text/css">
		<link href="../easyui/css/glyphicons-halflings-regular.woff?v=202003150000" rel="stylesheet" type="text/css"> 
		<link href="../easyui/css/glyphicons-halflings-regular.ttf?v=202003150000" rel="stylesheet" type="text/css">
		<link href="../easyui/css/index.css?v=202003150000" rel="stylesheet" type="text/css">
		<link href="../easyui/css/shippingtool.main.css?v=202003150000" rel="stylesheet" type="text/css">
			<link href="../easyui/css/easyui.css" type="text/css" rel="stylesheet" />
		    <script src="../easyui/js/jquery-1.11.2.js" type="text/javascript" ></script>
		    <script src="../easyui/js/jquery.easyui.min.js" type="text/javascript" ></script>
		    <script src="../easyui/js/easyui-lang-zh_CN.js" type="text/javascript" ></script>
		    <script src="../easyui/js/jquery.shippingtool.extend.validate.js" type="text/javascript" ></script>
		    <script src="../easyui/js/jquery.shippingtool.plugin.js" type="text/javascript" ></script>
	</head>
		
<script>
	function checkOldPassWord(password){
		if(password==""){
			 $("#passwordError").removeClass("hidden");
			 return;
		}
		$.ajax({url:"/houtai/myaccount/checkpassword",
			type: "GET",
			data:{"password":password},
			error: function(){
                 $("#passwordError").removeClass("hidden");
            },success: function(data){
        		if(data.success){
					$("#passwordError").addClass("hidden");
				}else{
    				$("#passwordError").removeClass("hidden");
				}
    		}
		});
	}
	
	<!--验证密码等级-->
	function checkpwdLevel(password){
		$("#passwordlevelSpan").removeClass("hidden");
		if(password.length < 7 || password.length>20){
           $('#passwordlevelSpan').html('<font color="red">密码长度介于7-20位</font>');
			return false;
    	}
		var ls=0;
        if(password.match(/([0-9])+/)){
           ls++;
        }
         
        if(password.match(/[a-zA-Z]+/)){
        	ls++;  
        }
        if (ls==2){
			$('#passwordlevelSpan').html('<font color="green">密码符合安全要求</font>');
			return true;
		}else{
			$('#passwordlevelSpan').html('<font color="red">密码不符合安全要求</font>');
			return false;
		}
	}
	
	<!--验证两次输入密码是否一致-->
	function validatePassWordV(){
		var newLoginPassWord=$("#newLoginPassWord").val();
		var validatePassWord=$("#validatePassWord").val(); 
		if(newLoginPassWord==validatePassWord){
			$("#validatePassWordError").addClass("hidden");
			return true;
		}else{
			$("#validatePassWordError").removeClass("hidden");
			return false;
		}
	}
	
	function saveLoginPassword(){
		var isSameFlag=validatePassWordV();//两次密码输入是否一致
		var validate = $('#passwordForm').form("validate");
		var newLoginPassWord=$("#newLoginPassWord").val();
		var oldpassword=$("#loginPassWord").val();
		var isSafeFlag=checkpwdLevel(newLoginPassWord);
		
		if(!(validate&&isSameFlag&&isSafeFlag)){
			return;
		}
	
		var isHasError=$("#passwordError").hasClass("hidden");
		if(!isHasError){
			return;
		}
		
		if(validate&&isSameFlag&&isSafeFlag){
			$("#saveLoginPasswordBut").linkbutton('disable'); 
			$.ajax({ 
    			url: "/houtai/myaccount/updatepassword",
    			type: "POST",
    			data:{	"password":newLoginPassWord,},
    			async: false,
    			dataType:"json", 
    			error:function(){
    				jQuery.messager.alert('错误','密码修改错误，请稍后重试','error');
                },
				success: function(data){
            		if(data.success){  
    					$("#validatePassWordError").addClass("hidden");
						$("#passwordError").addClass("hidden");
						$("#passwordlevelSpan").addClass("hidden");
						$("#passwordForm").form("clear");
						$.messager.show({msg:'修改密码成功!',timeout:2400,showType:'slide',height:50});
    				}else{
						$.messager.alert('错误','密码修改错误，请稍后重试','error'); 
    				}
					$("#saveLoginPasswordBut").linkbutton('enable');  
        		}
    		});
		}
	} 
</script>
	<body>
		<div class="main-l bgfff ld-auto-height w_100 p_10">
			<div class="ld-auto-height center w_90" > 
				<div class="mt_10"><span style="font-size:28px;">修改密码</span></div>
				<div style="border-bottom: 1px solid #999;margin:10px 0"></div>
				<form id="passwordForm" method="post">
		    		<div class="mt_20">
		    			<table class="package" width="100%">
		    				<tbody>
		        				<colgroup>
		        					<col width="20%">
									<col width="38%">
									<col width="32%">
		        				</colgroup>
		    					<tr>
		        					<td class='tr'><span style="font-size:18px;">当前使用的密码</span></td>
		        					<td>
		    							<span class="ml_10">
		            						<input class="easyui-validatebox textbox h25 w200" onBlur="checkOldPassWord(this.value)" type="password" id="loginPassWord" data-options="required:true,missingMessage:'请输入旧密码'"/>
		            						<span id="passwordError" style="font-size:14px;" class="ml_5 hidden fg_red">密码错误</span>
		            					</span>
		    						</td>
									<td></td>
		    					</tr>
		    					<tr>
		        					<td class='tr'><span style="font-size:18px;">设置新密码</span></td>
		        					<td>
		    							<span class="ml_10"> 
		    								<input class="easyui-validatebox textbox h25 w200" type="password" id="newLoginPassWord" onblur="checkpwdLevel(this.value)" data-options="required:true,missingMessage:'请输入新密码'" />
											<span id="passwordlevelSpan" style="font-size:14px;"></span>
		                				</span>
		    						</td>
									<td rowspan='2'>
										<div><span style="font-size:16px;">长度最少7位最多20位</span></div>
										<div><span style="font-size:16px;">必须包含字母</span></div>
										<div><span style="font-size:16px;">必须包含数字</span></div>
									</td>
		    					</tr> 
		    					<tr>
		        					<td align="right"><span style="font-size:18px;">确认新密码</span></td>
		        					<td align="left">
		    							<span class="ml_10">
		            						<input class="easyui-validatebox textbox h25 w200" type="password" onBlur="validatePassWordV()" id="validatePassWord" data-options="required:true,missingMessage:'请确定新密码'" />
		            						<span id="validatePassWordError" style="font-size:14px;" class="ml_5 hidden fg_red">两次密码输入不一致</span>
		                				</span>
		    						</td>
									<td></td>
		    					</tr>
								<tr>
		    						<td></td>
		                            <td><a href="javascript:void(0)" class="easyui-linkbutton c1" id="saveLoginPasswordBut"  onclick="saveLoginPassword()">确定 </a></td>
									<td></td>
		    					</tr>
		    				</tbody>
		        		</table>
		        	</div>	
				</form>  
			</div>		 
		</div>
	</body>
</html>
